<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>留言板</title>
	<link rel="stylesheet" href="./tpl/layui/css/layui.css">
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
	<script src="./tpl/layui/layui.js"></script>
</head>
<body>
	<ul class="layui-nav" lay-filter="">
	  <li class="layui-nav-item"><a href="">最新活动</a></li>
	  <li class="layui-nav-item layui-this"><a href="">产品</a></li>
	  <li class="layui-nav-item"><a href="">大数据</a></li>
	  <li class="layui-nav-item">
	    <a href="javascript:;">解决方案</a>
	    <dl class="layui-nav-child"> <!-- 二级菜单 -->
	      <dd><a href="">移动模块</a></dd>
	      <dd><a href="">后台模版</a></dd>
	      <dd><a href="">电商平台</a></dd>
	    </dl>
	  </li>
	  <li class="layui-nav-item"><a href="">登录</a></li>
	  <li class="layui-nav-item"><a href="./reg.php">注册</a></li>
	</ul>
	<div style="padding: 20px; background-color: #F2F2F2;">
      <form class="layui-form layui-form-pane" style="margin-top: 50px">
      <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
          <input type="text" name="username" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input" value="zhibin">
        </div>
        <div class="layui-form-mid layui-word-aux">辅助文字</div>
      </div>
		  <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
          <input type="password" name="password" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input" value="123456">
        </div>
        <div class="layui-form-mid layui-word-aux">辅助文字</div>
      </div>
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="reg">登录</button>
		    </div>
		  </div>
		</form>
    </div>
	<script>

		//注意：导航 依赖 element 模块，否则无法进行功能性操作
		layui.use(['element','form'], function(){
		  var element = layui.element;
		  var form = layui.form;
      //监听提交
      form.on('submit(reg)', function(data){
        // layer.msg(JSON.stringify(data.field));

        $.post('./checklogin.php',data.field, function(res, textStatus, xhr) {

            if(res.error==1){
              layer.msg(res.msg, function(){});
            }else{
              layer.alert(res.msg, {icon: 6},function () {
                  location.href="./index.php";
              });
            }
        },'json');

        return false;
      });
		});
	</script>

</body>
</html>